<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <div class="contentsize">委托运营-合同信息录入</div>
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div style="overflow: hidden;">
                <!-- max-height="330" -->
                <el-table :data="sjtableData" style="width: 100%" :header-cell-style="tableHeaderColor"
                    :row-style="tablerowColor" :row-class-name="tableRowClassName" :cell-style="tablecellColor" border :max-height="maxHeight">
                    <el-table-column prop="bz" label="当前节点" align="center"> </el-table-column>
                    <el-table-column prop="sssw" label="所属事务名称" align="center"> </el-table-column>
                    <el-table-column prop="dz" label="地址" align="center" width="280" :show-overflow-tooltip="true"> </el-table-column>
                    <el-table-column prop="addusername" label="发起人" align="center"> </el-table-column>
                    <el-table-column prop="adddatetime" label="发起日期" align="center">
                        <template slot-scope="scope">
                            {{ scope.row.adddatetime ? scope.row.adddatetime.split(' ')[0] : '' }}
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="100" align="center">
                        <template slot-scope="scope">
                            <el-button type="text" size="small"
                                @click="gotosjym(scope.row.processcode, scope.row.id)">办理</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div class="pagination" style="float: right">
                    <el-pagination background layout="total,prev, pager, next,jumper" :total="sjtotal" :current-page.sync="sjcurrent"
                        :page-size="pageSize" @current-change="sjhandleCurrentChange">
                    </el-pagination>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import { gdcaselist, dbnodelete,gddbnodelist } from '@/api/index';
import valueList from '@/components/common/valueList.vue'
export default {
    name: 'gdlist',
    data() {
        return {
            ssswlist: valueList.ssswlist,//所属事物列表
            total: 0,
            current: 1,
            sjtotal: 0,
            sjcurrent: 1,
            pageSize: 10,
            form: {
                adduser:this.$store.getters.userId,
                caseid: '',//流程实例id,
                create_name: '',//创建人,
                create_name_id: '',//创建人id,
                create_time: '',//创建时间,
                current: 1,// 第几页 ,
                fj: '',//归档附件 ,
                gdjl: '',//归档记录 ,
                id: '',//id ,
                pageSize: 10,// 每页数量 ,
                status_code: 1,// 1正常 2删除 ,
                update_name: '',//修改人 ,
                update_name_id: '',//修改人id ,
                update_time: '',//修改时间 ,
                zt: 0//归档状态 0：待办 1：已办
            },
            gdform: {
                adddatetime: '',// 发起日期 ,
                adduser: '',// 发起人ID ,
                addusername: '',// 发起人姓名 ,
                bz: '',// 步骤（当前节点） ,
                current: 1,//第几页 ,
                dabh: '',// 档案编号 ,
                dz: '',// 地址 ,
                id: '',// id ,
                pageSize: 10,// 每页数量 ,
                processcode: '',// 流程模板编码(例：fwjg) 所属事务编码 ,
                sssw: '',// 所属事务名称 ,
                userid: this.$store.getters.userId,// 当前用户ID
            },
            tableData: [],
            sjtableData:[],//数据归档
            ztlist: [{ name: '是', code: 1 }, { name: '否', code: 0 }],
            maxHeight:null
        };
    },
    components: {},
    computed: {},
    methods: {
        // 列表样式
        tableHeaderColor({ row, column, rowIndex, columnIndex }) {
            if (rowIndex === 0) {
                return 'background:linear-gradient(to bottom, #008A94,#0ae2f2)!important;color:#ffffff;font-size:14px;'
            }
        },
        tablerowColor({ row, rowIndex }) {
            return 'height: 42px;font-size:14px;color:black'
        },
        tablecellColor(){
            return "font-weight:700;color:#000000;border-color:#c0c0c0";
        },
        tableRowClassName({ row, rowIndex }) {
            if (rowIndex % 2 != 0) {
                return 'success-row' //这是类名
            } else {
                return ''
            }
        },
        // 换页
        handleCurrentChange(val) {
            this.current = val;
            this.form.current = val;
            this.gdcaselist(this.form);
            console.log(val);
        },
        // 换页
        sjhandleCurrentChange(val) {
            this.sjcurrent = val;
            this.gdform.current = val;
            this.gddbnodelist(this.gdform);
            console.log(val);
        },
        // 搜索
        onSearch() {
            this.current = 1;
            this.form.current = 1;
            this.gdcaselist(this.form);
            console.log('搜索');
        },

        // 项目列表
        gdcaselist(data) {
            gdcaselist(data).then((res) => {
                if (res.code == 200) {
                    this.tableData = res.data.records;
                    this.total = res.data.total;
                } else {
                    this.tableData = [];
                    this.total = 0;
                }
            });
        },
         // 数据归档列表
         gddbnodelist(data) {
            gddbnodelist(data).then((res) => {
                if (res.code == 200) {
                    this.sjtableData = res.data.records;
                    this.total = res.data.total;
                } else {
                    this.sjtableData = [];
                    this.total = 0;
                }
            });
        },
        // 跳转流程页面
        gotofwjg(val, id) {
            let name = val + 'gd'
            this.$router.push({
                name: name,
                params: { id: id }
            });
        },
        // 跳转数据归档页面
        gotosjym(val, id) {
            let name = val + 'val'
            this.$router.push({
                name: name,
                params: { id: id }
            });
        },
    },
    mounted() {
        this.$nextTick(() => {
            // window.innerHeight 浏览器窗口的可见高度，下面的 420 是除了table最大高度的剩余空间。
            this.maxHeight = window.innerHeight - 400
        })
        console.log(this.$store.getters)
        // this.gdcaselist(this.form);
        this.gddbnodelist(this.gdform)
        console.log(valueList)
    }
};
</script>

<style scoped>
.container {
    /* height: calc(100vh - 250px); */
    overflow: hidden;
}

.crumbs {
    background-color: #fff;
    padding: 20px 20px;
}

.indexTitle {
    margin-bottom: 20px;
}

.contentsize {
    font-size: 18px;
    font-weight: 700;
}

.handle-box {
    overflow: hidden;
}

/* 新增按钮 */
.addcolor {
    margin-bottom: 10px;
}

.unloadTitle {
    text-align: left;
    padding-bottom: 10px;
    box-sizing: border-box;
    color: #606266;
}

.lxstyle {
    padding: 6px 20px;
    border: 1px #e8e9fb solid;
    width: 130px;
    box-sizing: border-box;
    border-radius: 20px;
    text-align: center;
    color: #008A94;
    box-shadow: 0 0 10px #e8e9fb;
    margin-bottom: 10px;
}</style>
<style>
.success-row {
    background-color: #eaf3fb !important;
}
</style>
